package com.hn.gege.sys.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hn.gege.sys.modules.sys.service.IDictService;
import com.hn.gege.sys.modules.sys.entity.Dict;
import com.hn.gege.sys.modules.sys.mapper.DictMapper;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 字典类别表 服务实现类
 * </p>
 *
 * @author zxy
 * @since 2020-08-06
 */
@Service
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements IDictService {

    @Override
    public Dict getByPk(String dictType) {
        LambdaQueryWrapper<Dict> lambda = new QueryWrapper<Dict>().lambda()
                .eq(Dict::getDictType, dictType);
        return baseMapper.selectOne(lambda);
    }

    @Override
    public boolean updateByPk(Dict dict) {
        LambdaQueryWrapper<Dict> lambda = new QueryWrapper<Dict>().lambda()
                .eq(Dict::getDictType, dict.getDictType());
        return super.update(dict, lambda);
    }

    @Override
    public boolean removeByPk(String dictType) {
        LambdaQueryWrapper<Dict> lambda = new QueryWrapper<Dict>().lambda()
                .eq(Dict::getDictType, dictType);
        return super.remove(lambda);
    }

}
